
//Java类的配置
@Component
@ManagedResource
public class PackageServiceChargeBill {
	private @Resource ServiceChargeSubService serviceChargeSubService;
	
	@ManagedOperation
	public void run() {
		//调用打包程序
		serviceChargeSubService.packageServiceChargeBill();
	}
}

//spring-task.xml的配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:task="http://www.springframework.org/schema/task"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
	http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
    http://www.springframework.org/schema/task
    http://www.springframework.org/schema/task/spring-task-4.1.xsd">



  <task:scheduled-tasks>
    <!-- 企业订单截止日, 提醒企业管理员付款,xxxxx-xx-xx 09:30 AM 每天9:30-->
    <task:scheduled ref="remindCustomerDealInsOrderTimer" method="remindCustomerPayInsOrder" cron="${remindCustomerDealInsOrderTimer.remindCustomerPayInsOrder}"/>
  </task:scheduled-tasks>
  

  <!-- 每月月底生成供应商服务费单 -->
  <bean id="packageServiceChargeBill" class="com.ayg.insurance.timer.PackageServiceChargeBill"></bean>
  <!-- 创建调度任务 -->
  <bean id="task" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> 
        <property name="targetObject">   
            <!-- 要调度的类 -->    
            <ref bean="packageServiceChargeBill"/>     
        </property>     
        <property name="targetMethod">    
            <!-- 要调度的方法名称 -->   
            <value>run</value>     
        </property>     
  </bean>
  <!-- 配置调度任务 -->  
  <bean id="cronTrigger"    
        class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">     
        <property name="jobDetail">     
            <ref bean="task"/>     
        </property>     
        <property name="cronExpression">     
            <!--0 15 04 L * ? 配置每个月的最后一天的04点15分-->     
            <value>0 15 04 L * ?</value>     
        </property>     
   </bean>  
   <!-- 启动调度 -->  
   <bean autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">     
        <property name="triggers">     
            <list>     
                <ref bean="cronTrigger" />     
            </list>     
        </property>     
  </bean>  
</beans>

//properties文件的配置
packageBusinessBill.run=0 0 3 * * *
## 每年5月2号执行(当前时间已过5月2号，故如下为禁止执行的配置)
remindCustomerDealInsUserInfoTimer.remindCustomerAddInsUserInfo=0 10 9 2 5 ?


//pom.xml
<!-- 由于spring task:scheduled cron不支持配置字母类型的表达式；所以使用quartz  -->
    <dependency>
      <groupId>org.quartz-scheduler</groupId>
      <artifactId>quartz</artifactId>
    <version>2.2.1</version>
    </dependency>